import React, {Component} from 'react';
import ReactDom from 'react-dom';
import { FormattedMessage, injectIntl } from 'react-intl';
import {actions} from "mirrorx";
import {InputNumber, Select, Button, Modal, Message} from "tinper-bee";
import Radio from 'bee-radio';
import moment from 'moment'
import DatePicker from "bee-datepicker";
import FormError from 'components/FormError';
import RefComponent from 'components/RefComponent';
import FormList from 'components/FormList'

let {RangePicker} = DatePicker;

import './index.less'

const FormItem = FormList.Item;

class CreateCustomer extends Component {
    constructor(props) {
        super(props);
        this.state = {
        }

    }
    

    createCustomer = (delFlag) => {
        let { selectData } = this.props;
    
        if (delFlag) {
            this.props.form.validateFields((err, _values) => {
                // let supplierCategoryId = _values.supplierCategoryId && JSON.parse(_values.supplierCategoryId).refpk;
                // if(!supplierCategoryId) {
                //     err = true;
                // }
                // if(err) {
                //     Message.create({ content: '请输入值', color: 'warning' });
                // }else {
                    let params=[]
                    selectData.map(item => {
                        params.push({
                            id:item.id,
                            ..._values
                        })
                    })
                    
                    actions.PromoterChange.createCustomer(params);
                    this.props.closeCreateModal();
                // }
                
            })

            
            
        }else {
            this.props.closeCreateModal();
        }
        

    }


    render() {
        let {form,onCallback,showCreateCustomerModal} = this.props;
        let { getFieldProps, getFieldError } = this.props.form;

        let self = this;
       
        return (
            <Modal
            show={showCreateCustomerModal}
            size={"lg"}
            onHide={this.createCustomer} >
            <Modal.Header>
                <Modal.Title>订单批改</Modal.Title>
            </Modal.Header>

            <Modal.Body className="ucf-exam-form">
                <FormList size="sm">
                    <FormItem
                        className="time"
                        key={"baseSalary"}
                        label={"薪资"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`baseSalary`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />

                    </FormItem>
                    <FormItem
                        className="time"
                        key={"JobTitle"}
                        label={"劳动费用"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`JobTitle`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"ContractWage"}
                        label={"合同工资"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`ContractWage`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"PersonalSecurity"}
                        label={"个人社保"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`PersonalSecurity`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"PaymentBase"}
                        label={"公司社保"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`PaymentBase`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"Accumulationfund"}
                        label={"公积金"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`Accumulationfund`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"Commissionratio"}
                        label={"提成系数"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`Commissionratio`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"postcoefficient"}
                        label={"岗位系数"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`postcoefficient`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"ratiorank"}
                        label={"级别系数"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`ratiorank`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"addtoratio"}
                        label={"变动/追加系数"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`addtoratio`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                    <FormItem
                        className="time"
                        key={"years"}
                        label={"工龄"}
                    >
                        <InputNumber toThousands={true}
                            min={0} step={1} precision={2}
                            iconStyle="one" step={1} 
                            {...getFieldProps(`years`, {
                                initialValue: "0",
                                rules: [{ message: "请输入" }],
                            })}
                        />
                    </FormItem>
                </FormList>
            </Modal.Body>

            <Modal.Footer>
                <Button onClick={() => this.createCustomer(false)} style={{ marginRight: 10 }}><FormattedMessage id="js.Ref.Ref224.0012" defaultMessage="关闭" /></Button>
                <Button onClick={() => this.createCustomer(true)} ><FormattedMessage id="js.com.Pas.0005" defaultMessage="确定" /></Button>
            </Modal.Footer>
        </Modal>

        )
    }
}

export default FormList.createForm()(injectIntl(CreateCustomer))
